/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.CalendarResourceBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.CalendarResource;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.MailboxManager;
/*    */ import com.zimbra.soap.JaxbUtil;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.admin.message.DeleteCalendarResourceRequest;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class DeleteCalendarResource
/*    */   extends AdminDocumentHandler
/*    */ {
/* 43 */   private static final String[] TARGET_RESOURCE_PATH = { "id" };
/*    */   
/* 45 */   protected String[] getProxiedResourcePath() { return TARGET_RESOURCE_PATH; }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   public boolean domainAuthSufficient(Map context)
/*    */   {
/* 52 */     return true;
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   public boolean defendsAgainstDelegateAdminAccountHarvesting()
/*    */   {
/* 60 */     return true;
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 68 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 69 */     Provisioning prov = Provisioning.getInstance();
/* 70 */     DeleteCalendarResourceRequest req = (DeleteCalendarResourceRequest)JaxbUtil.elementToJaxb(request);
/* 71 */     String id = req.getId();
/*    */     
/*    */ 
/* 74 */     CalendarResource resource = prov.get(Key.CalendarResourceBy.id, id);
/* 75 */     defendAgainstCalResourceHarvesting(resource, Key.CalendarResourceBy.id, id, zsc, Rights.Admin.R_deleteCalendarResource);
/*    */     
/* 77 */     if (!Provisioning.onLocalServer(resource))
/*    */     {
/*    */ 
/* 80 */       throw ServiceException.WRONG_HOST(resource.getAttr("zimbraMailHost"), null);
/*    */     }
/* 82 */     Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(resource);
/*    */     
/* 84 */     prov.deleteCalendarResource(id);
/* 85 */     mbox.deleteMailbox();
/*    */     
/* 87 */     ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "DeleteCalendarResource", "name", resource.getName(), "id", resource.getId() }));
/*    */     
/*    */ 
/* 90 */     Element response = zsc.createElement(AdminConstants.DELETE_CALENDAR_RESOURCE_RESPONSE);
/* 91 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 96 */     relatedRights.add(Rights.Admin.R_deleteCalendarResource);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/DeleteCalendarResource.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */